<?php
namespace Anls\Common;

class Redis  {
    
    // 交易记录
    public static $TRADE_LOG_KEY = "trade:log:";
    // 交易代码
    public static $TRADE_CODE_KEY = "trade:codes";
    // 交易分析
    public static $TRADE_ANLS_KEY = "trade:anls:";
    // 过滤代码
    public static $FILTER_CODES_KEY = 'filter:codes';
    // 控制台
    public static $CONSOLE_CUR_KEY = "cs:cur";
    public static $CONSOLE_ALL_KEY = "cs:all";
    public static $CONSOLE_LOG_KEY = "cs:log";
    
    public static function deleteKeys($redis,$key){
        $keys = $redis->keys($key.'*');
        return $redis->del($keys);
    }
    
    public static function deleteKey($redis,$key){
        return $redis->del($key);
    }
    
    public static function log($redis,$msg,$isBr = true){
        /*
        $_msg = $redis->get(self::$CONSOLE_LOG_KEY);
        if($isBr){
            $msg = $_msg . '</br>' . $msg;
        } else {
            $msg = $_msg . $msg;
        }
        $redis->set(self::$CONSOLE_LOG_KEY,$msg);
        */
    }
    
    public static function clearLog($redis){
        $redis->del(self::$CONSOLE_LOG_KEY);
    }
    
    public static function getLog($redis){
        return $redis->get(self::$CONSOLE_CUR_KEY);
    }
    
}